﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class UVMove2 : MonoBehaviour {

	private Renderer _renderer;
	private Material _material;
	/// <summary>
	/// The offset.
	/// </summary>
	public Vector2 offset;
	public float uv_x = 0.0f;
	public float uv_y = 0.0f;



	void Awake()
	{
		_renderer = this.gameObject.GetComponent<Renderer>();
		_material = _renderer.material;
		offset = _material.GetTextureOffset("_MainTex");

	}


	// Use this for initialization
	void Start () {
		
	}
	
	// Update is called once per frame
	void Update () {
//		_offset.x += 0.5f * Time.deltaTime;
		if(null != _material)
		{
			offset.x += uv_x * Time.deltaTime;
			Mathf.Repeat(offset.x,1.0f);
			offset.y += uv_y * Time.deltaTime;
			Mathf.Repeat(offset.y,1.0f);
			_material.SetTextureOffset("_MainTex",offset);
		}
	
	}
}
